<?php
	class UserSearchForm extends Zend_Form{
		public function __construct($userType, $options = null){
			parent::__construct($options);
			$this->addPrefixPath('Vmg_Form_Decorator', 'Vmg/Form/Decorator', 'decorator');

			// load translator
			$registry = Zend_Registry::getInstance();
			$translate = $registry->get('Zend_Translate');
			$access_levels = $registry->get('access_level_config');

			// set up form
			$this->setName('usersearch');
			$this->setAttrib('id', 'usersearchForm');

			$user_name = new Zend_Form_Element_Text("nameUserSearchForm");
			$user_name->setLabel($translate->_("Name"))
			->addFilter('StripTags')
			->addFilter('StringTrim')
			->setDecorators(array("Composite"))
			->setAttrib('size', 10);
			;

			$user_type = new Zend_Form_Element_Select('typeUserSearchForm'); // type
			$user_type->setLabel($translate->_("Type of users") )
			->addFilter('StripTags')
			->addFilter('StringTrim')
			->setDecorators(array('Composite'))
			;

			$user_type->addMultiOption(-1, "All types");
			$types = new UserTypes();
			$type_array =  $types->fetchAll('access_level = ' . $userType);
			foreach($type_array as $type){
				$user_type->addMultiOption((int)$type->id, (string)$type->type_name);
			}

			$submit = new Zend_Form_Element_Submit('submitUserSearchForm');
			$submit->setAttrib('id', 'submitUserSearchForm');
			$submit->setLabel('')
				->setValue($translate->_('Search'))
				->setDecorators(array("Composite"))
			;

			$this->addElements(array($user_name, $user_type, $submit));
		}
	}
?>